import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2022-10-12
 * Time: 15:21
 */
public class TestDemo {
    public static void print2(int n){
        if (n<10){
            System.out.print(n%10+" ");
        } else {
            print2(n/10);
            System.out.print(n%10+" ");
        }
    }
    public static void main(String[] args) {
        int n = 1234;
        print2(n);
    }
    public static int numMul(int n){
        if (n==1){
            return 1;
        } else {
            return n*numMul(n-1);
        }
    }
    public static void main15(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(numMul(n));
    }

    public static int sumAdd(int n){
        if(n == 1){
            return 1;
        } else {
            return n+sumAdd(n-1);
        }
    }
    public static void main14(String[] args) {
        int n = 10;
        System.out.println(sumAdd(n));
    }
    public static int factor(int n){
        if (n == 1){
            return 1;
        } else {
            return n * factor(n-1);
        }
    }
    public static void main13(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n = scanner.nextInt();
            int ret = factor(n);
            System.out.println(ret);
        }
    }
    public static void main12(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入数字：");
        int value=scan.nextInt();
        System.out.println("偶数序列：");
        for(int i=31;i>0;i-=2){
            System.out.print((value>>i)&1);
        }
        System.out.println("");
        System.out.println("奇数序列：");
        for(int i=30;i>=0;i-=2){
            System.out.print((value>>i)&1);
        }
    }
    public static long fibonacci(int n) {
        if (n < 1) {
            return -1;
        }
        if (n ==1 || n == 2) {
            return 1;
        }
        long a =1l, b= 1l, c =0l;		//定义三个long类型整数
        for (int i = 0; i < n - 2; i++) {
            c = a + b;			//第3个数的值等于前两个数的和
            a = b;			//第2个数的值赋值给第1个数
            b = c;			//第3个数的值赋值给第2个数
        }
        return c;
    }
    public static void main11(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(fibonacci(n));
    }
    public static void main10(String[] args) {
        int[]array = {1,2,3,4,5};
        int left = array[0];
        int right = array.length-1;
        while(left < right) {
            while (left < right && array[left] % 2 != 0){
                left++;
            }
            while (left < right && array[right] % 2 == 0){
                right--;
            }
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
            }
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
    }
    public static int Max(int a,int b){
        return a > b? a : b;
    }
    public static int Max(int a,int b,int c){
        return Max(Max(a,b),c);
    }
    public static void main9(String[] args) {
        int a = 10;
        int b = 20;
        int c = 30;
        System.out.println(Max(a,b));
        System.out.println(Max(a,c));
        System.out.println(Max(b,c));
        System.out.println(Max(a,b,c));
    }
    public static void main8(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + j*i + "  ");
            }
            System.out.println();
        }
    }
    public static void main7(String[] args) {
        int n = 4567;
        print(n);
    }
    public static int num(int n){
        int sum = 0;
        int a = 1;
        for (int i = 1; i <= n; i++) {
            a *= i;
        }
        return a;
    }
    public static void print(int n){
        while (n != 0){
            System.out.print(n % 10 + " ");
            n /= 10;
        }
    }
    public static void main6(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(num(n));
    }
    public static void main5(String[] args) {
        int[] array = {1,2,3,2,1};
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum = sum ^ array[i];
        }
        System.out.println(sum);
    }
    public static void main4(String[] args) {
        int a = 18;
        int b = 24;
        int c = a % b;
        int d = a * b;
        while (c != 0){
            a = b;
            b = c;
            c = a % b;
        }
        System.out.println("这两个数的最大公因数为" + b);
        System.out.println("这两个数的最小公倍数为" + d/b);
    }
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if ((i == j) || (i + j + 1 == n)) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }
    public static void main1(String[] args) {
        Random random = new Random();
        int rand = random.nextInt(100);
        Scanner scanner = new Scanner(System.in);
        while (true){
            int n = scanner.nextInt();
            if (n > rand) {
                System.out.println("猜大了");
            } else if (n < rand) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜对了");
                break;
            }
        }
    }
}
